package com.salts.service.Impl;

import com.salts.Dao.AddressMapper;
import com.salts.domain.po.UserAddress;
import com.salts.service.AddressService;
import com.salts.util.GetNowDateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class AddressServiceImpl implements AddressService {
    @Autowired
    AddressMapper addressMapper;
    @Override
    public boolean insertUserAddress(UserAddress userAddress) {
        Date nowDate = GetNowDateUtil.getNowDate();
        userAddress.setCreateTime(nowDate);
        userAddress.setUpdateTime(nowDate);
        return addressMapper.insertAddress(userAddress)>0;
    }

    @Override
    public boolean deleteUserAddress(Integer Id) {
        return addressMapper.deleteAddress(Id)>0;
    }

    @Override
    public boolean updateUserAddress(UserAddress userAddress) {
        Date nowDate = GetNowDateUtil.getNowDate();
        userAddress.setUpdateTime(nowDate);
        return addressMapper.updateAddress(userAddress)>0;
    }

    @Override
    public List<UserAddress> selectAllUserAddress(Integer userId) {
        return addressMapper.selectAddress(userId);
    }
}
